<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% 

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>普通用户</title>
<link type="text/css" rel="stylesheet" href="<%=basePath %>jquery-easyui-1.4.2/themes/default/easyui.css">
<link type="text/css" rel="stylesheet" href="<%=basePath %>jquery-easyui-1.4.2/themes/icon.css">
<script type="text/javascript" src="<%=basePath %>js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="<%=basePath %>jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath %>jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath %>js/dateFormat_CY.js"></script>
<script type="text/javascript">
	$(function(){
		var firstDataValue = $("#firstData").datebox('getValue');
		var nextDataValue = $("#nextData").datebox('getValue');
		var url = "www.baidu.com";
		//设置初始的日期时间
		/* $('#nextData').datebox('setValue', getnextDataStr()); */
  			/*$('.updateData').datebox('calendar').calendar({  
	        validator : function(date){  
	            var now = new Date();  
	            var d1 = new Date(now.getFullYear(),now.getMonth(),now.getDate());  
	            return date <= d1;  
	        }  
		});*/ 
		//分页界面与分页栏
		$('#dg').datagrid({
			url:'<%=basePath%>bulletin/selectBulletinOrNotice.do',
			pagination:true,
			queryParams:{pageNo:1,pageSize:10,category:"<%=request.getParameter("name")%>",firstData:firstDataValue,nextData:nextDataValue,title:""},
			rownumbers:true,
			striped:true,
			singleSelect:true,
			columns:[[
				{field:'bn_id',title:'标题id',width:100,hidden:true},
				{field:'title',title:'标题',width:500,halign: 'center',formatter:function(title,rows){
					return "<a href='<%=basePath%>bulletin/bulletinContent.do?bn_id="+rows.bn_id+"'>"+title+"</a>";
				}},
				{field:'category',title:'类别',width:90,align:'center',halign: 'center'},
				{field:'time',title:'更新日期',width:200,align:'center',halign: 'center'},
				{field:'enclosureUrl',title:'附件',width:100,align:'center',halign: 'center',formatter:function(enclosureUrl){
					if(enclosureUrl == null){
						return "";
					}else {
						return "<a href='"+enclosureUrl+"'>下载</a>";
					}
					
				}},
				{field:'readNum',title:'已读人数',width:200,align:'center',halign: 'center'}
			]]
			
		});	 
		//分页
		var page=$("#dg").datagrid("getPager");
		page.pagination({
			onSelectPage:function(PageNumber,pageSize){
				var firstData = $("#firstData").datebox('getValue');
				var nextData = $("#nextData").datebox('getValue');
				var title = $("#searchTitle").val();
				var category="<%=request.getParameter("name")%>";
				$('#dg').datagrid("load",{pageNo:PageNumber,pageSize:pageSize,category:category,firstData:firstData,nextData:nextData,title:title});
				page.pagination({
					pageNumber:PageNumber,
					pageSize:pageSize
				});
				
			}
		})
	})
	
	//初始日期时间的计算
	//初始日期时间的计算
	function getnextDataStr()  {   
	    var now = new Date();  
	    var year = now.getFullYear();       //年  
	    var month = now.getMonth() +1;     //月  
	    var day = now.getDate();            //日  
	    var clock = year + "-";  
	    if(month < 10) clock += "0";         
	    clock += month + "-";  
	    if(day < 10) clock += "0";   
	    clock += day;  
	    return clock;   
	} 
	//模糊查询
	function search() {
		var title = $("#searchTitle").val();
		var firstData = $("#firstData").datebox('getValue');
		var nextData = $("#nextData").datebox('getValue');
		var category="<%=request.getParameter("name")%>";
		$("#dg").datagrid("load",{pageNo:1,pageSize:10,category:category,firstData:firstData,nextData:nextData,title:title});
		
	}
	//所有查询
	function allSearch() {
		var title = "";
		var firstData = "";
		var nextData = "";
		var category="<%=request.getParameter("name")%>";
		$("#dg").datagrid("load",{pageNo:1,pageSize:10,category:category,firstData:firstData,nextData:nextData,title:title});
		$('#nextData').datebox('setValue', getnextDataStr());
		$('#firstData').datebox('setValue', null);
		$('#searchTitle').val('');
	}
	</script>
	</head>
	
	<body>
		<div>
			<samp>更新日期：</samp>
			<input id="firstData" type="text" class="easyui-datebox updateData" required="required"></input> 
			<samp>至：</samp> 
			<input id="nextData" type="text" class="easyui-datebox updateData"  required="required"></input> 
			<samp>标题：</samp> 
			<input type="test" id="searchTitle" class="input" placeholder="输入要查询的标题"/>
			<a href="javascript:search();" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
			<a href="javascript:allSearch();" class="easyui-linkbutton" data-options="iconCls:'icon-search'">所有查询</a>
		</div>
		<table id="dg" ></table>
	</body>
</html>
